package com.lvmama.pangolin.service.impl.configImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.pangolin.common.StringTools;
import com.lvmama.pangolin.entity.Config;
import com.lvmama.pangolin.entity.JobConfig;
import com.lvmama.pangolin.entity.JobListConditionVO;
import com.lvmama.pangolin.entity.Timer;
import com.lvmama.pangolin.entity.TimerListConditionVO;
import com.lvmama.pangolin.mybatis.mapper.config.BackJobConfigMapper;
import com.lvmama.pangolin.service.config.BackJobConfigService;

@Transactional
@Service
public class BackJobConfigServiceImpl implements BackJobConfigService{
	/**   
	* @Title: LogServiceImpl.java  
	* @Description: TODO(用一句话描述该文件做什么) 
	* @author caobo 
	* @date 2017年0227
	*/
	@Autowired
	private BackJobConfigMapper backJobConfigMapper;

	@Override
	public PageInfo<Timer> getTimerList(TimerListConditionVO timerListConditionVO) throws Exception {
		 PageHelper.startPage(timerListConditionVO.getPage(), timerListConditionVO.getPageSize());
		 if(!StringTools.isValid(timerListConditionVO.getTimerStatus()))
    	 {
    		 timerListConditionVO.setTimerStatus("0");
    	 }
		 List<Timer> timerVoList = backJobConfigMapper.getTimerList(timerListConditionVO);
		 PageInfo<Timer> page = new PageInfo<Timer>(timerVoList);
	     return page;
	}

	@Override
	public List<Timer> getTimerByIds(Timer timer) throws Exception {
		// TODO Auto-generated method stub
		return backJobConfigMapper.getTimerByIds(timer);
	}

	@Override
	public void updateTimer(Timer timer) throws Exception {
		backJobConfigMapper.updateTimer(timer);	
	}

	@Override
	public PageInfo<JobConfig> getJobList(JobListConditionVO jobListConditionVO) throws Exception {
		 PageHelper.startPage(jobListConditionVO.getPage(), jobListConditionVO.getPageSize());
		 List<JobConfig> jobVoList = backJobConfigMapper.getJobList(jobListConditionVO);
		 PageInfo<JobConfig> page = new PageInfo<JobConfig>(jobVoList);
	     return page;
	}

	@Override
	public List<JobConfig> getJobByIds(JobConfig jobConfig) throws Exception {
		 List<JobConfig> jobVoList = backJobConfigMapper.getJobByIds(jobConfig);
		return jobVoList;
	}

	@Override
	public void updateJob(JobConfig jobConfig) throws Exception {
		backJobConfigMapper.updateJob(jobConfig);
	}

	@Override
	public void deleteJob(JobConfig jobConfig) throws Exception {
		backJobConfigMapper.deleteJob(jobConfig);
	}

	@Override
	public List<JobConfig> getJobChildsList(JobConfig jobConfig) throws Exception {
		List<JobConfig> jobChildList = backJobConfigMapper.getJobChildList(jobConfig);
		return jobChildList;
	}

	@Override
	public void addJob(JobConfig jobConfig) throws Exception {
		backJobConfigMapper.addJob(jobConfig);
	}

	
   }
